package com.e3.basdoc.corp.client;

import java.util.ArrayList;
import java.util.List;

import com.e3.basdoc.corp.model.CorpModel;
import com.e3.template.model.TGFFormModel;
import com.e3.template.tgf.TGFTabFormPanel;
import com.extjs.gxt.ui.client.widget.form.Field;

public class CorpFormPanel extends TGFTabFormPanel<CorpModel> {

	private final static String[] BASE_INFO = { CorpModel.ID, CorpModel.CREATE_USER_ID, CorpModel.CREATE_TIME, CorpModel.MODIFY_USER_ID,
			CorpModel.MODIFY_TIME, CorpModel.CODE, CorpModel.NAME, CorpModel.SHORT_NAME, CorpModel.TYPE, CorpModel.PARENT_CORP,
			CorpModel.REGION, CorpModel.BUSINESS_ADDRESS, CorpModel.CONTACT_ADDRESS, CorpModel.TELPHONE, CorpModel.FAX, CorpModel.ZIPCODE,
			CorpModel.EMAIL, CorpModel.REMARK };

	private final static String[] REGISTER_INFO = { CorpModel.REGISTER_ADDRESS, CorpModel.LEGAL_PERSON, CorpModel.LEGAL_PERSON_IDCARD,
			CorpModel.REGISTER_NO, CorpModel.TAX_NO, CorpModel.CONTACT_PERSON, CorpModel.CONTACT_WAY, CorpModel.FOUND_TIME,
			CorpModel.REGISTER_START_TIME, CorpModel.REGISTER_END_TIME, CorpModel.CURRENCY, CorpModel.TAXPAYER_TYPE };

	private final static String[] OTHERS = { CorpModel.ESTABLISH_ACCOUNT, CorpModel.MAX_USERS, CorpModel.MAX_BRANCHS, CorpModel.START_TIME,
			CorpModel.END_TIME };

	@Override
	public List<TGFFormModel> getFormModels() {
		
		List<TGFFormModel> formModels = new ArrayList<TGFFormModel>();
		
		String name = CorpMessages.INSTANCE.tab_base_info();
		List<Field<?>> fields = CorpHelper.INSTANCE.getFormFields(BASE_INFO);
		formModels.add(new TGFFormModel(0, name, fields));
		
		name = CorpMessages.INSTANCE.tab_register_info();
		fields = CorpHelper.INSTANCE.getFormFields(REGISTER_INFO);
		formModels.add(new TGFFormModel(1, name, fields));
		
		name = CorpMessages.INSTANCE.tab_other_info();
		fields = CorpHelper.INSTANCE.getFormFields(OTHERS);
		formModels.add(new TGFFormModel(2, name, fields));
		
		return formModels;
	}
	

	@Override
	public CorpModel createModelInstance() {
		return CorpHelper.INSTANCE.createModelInstance();
	}

}
